package OtherMethod;

public class StatisticAcmTable extends StatisticTable{
	
	public void ACT001_add(String title, double content) {
		boolean isAdd = false;
		Element newEle = new Element(title, 1);
		if(this.list.size() == 0) {
			this.list.add(0, newEle);
			isAdd = true;
		}
		else if(newEle.isEqualTitle(this.list.get(0))) {
			isAdd = true;
			this.list.get(0).content = this.list.get(0).content + 1;
		}
		else if(this.list.get(0).compareTitle(newEle)) {
			this.list.add(0, newEle);
			isAdd = true;
		}
		int index = 0;
		while(!isAdd && index < this.list.size() - 1) {
			Element curEle = this.list.get(index);
			if(newEle.isEqualTitle(curEle)) {
				isAdd = true;
				curEle.content = curEle.content + 1;
			}
			else if(newEle.compareTitle(curEle) && this.list.get(index + 1).compareTitle(newEle)) {
				isAdd = true;
				this.list.add(index + 1, newEle);
			}
			index = index + 1;
		}
		if(!isAdd) {
			if(newEle.isEqualTitle(this.list.get(this.list.size() - 1))) {
				this.list.get(this.list.size() - 1).content = this.list.get(this.list.size() - 1).content + 1;
			}
			else {
			    this.list.add(this.list.size(), newEle);
			}
			isAdd = true;
		}
	}
}